<?php
	class UserClient{
		protected $host='http://localhost:8080/gd_gdxt/gd_uc/api.php';
		public function curlPost($url,$post_data){
			$ch = curl_init(); //初始化curl
			curl_setopt($ch, CURLOPT_URL, $url);//设置链接
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//设置是否返回信息
			curl_setopt($ch, CURLOPT_HEADER, 0);
			curl_setopt($ch, CURLOPT_POST, 1);
			curl_setopt($ch, CURLOPT_POSTFIELDS,$post_data);
			$output = curl_exec($ch);
			curl_close($ch);
			return $output;
		}
		/**5
		*登陆远程接口
		*@param String uname
		*@param String pwd
		*@return mixed
		**/
		public function login($user,$pwd){
			$data = array(
				'action' => 'login',
				'user' => $user,
				'upw' => $pwd
				);
			return  curlPost($this->host,$data);
		}

		/**
		*注册远程接口
		*@param String uname 用户名
		*@param String pwd 密码
		*@param String email 邮箱
		*@param String register_ip 注册ip
		*@param String callback 激活注册跳转url
		*@return mixed
		**/
		public function register($uname,$pwd,$email,$register_ip,$callback){
			$data = array(
				'action' => 'register',
				'uname' => $user,
				'pwd' => $pwd,
				'email' => $email,
				'register_ip' => $register_ip,
				'callback_url' => $callback
				);
			return  curlPost($this->host,$data);
		}

		/**
		*获取token远程接口
		*@param String token
		*@return mixed
		**/
		public function online($token){
			$data = array(
				'action' => 'online',
				'token' => $token
				);
			return  curlPost($this->host,$data);
		}

		/**
		*获取token远程接口
		*@param String token
		*@return mixed
		**/
		public function modify($token){
			$data = array(
				'action' => 'modify',
				'token' => $token
				);
			return  curlPost($this->host,$data);
		}

		/**
		*获取token远程接口
		*@param String token
		*@return mixed
		**/
		public function logout($token){
			$data = array(
				'action' => 'logout',
				'token' => $token
				);
			return  curlPost($this->host,$data);
		}

		/**
		*写cookie（统一格式）
		*@param String token
		*@return mixed
		**/
		public function cookie_write($token){
			setcookie("CCUSER",$token,time()+3600*24*7);
		}

		/**
		*获取用户信息
		*@param String token
		*@return mixed
		**/
		public function getUserInfo($token){
			$data = array(
				'action' => 'userinfo',
				'token' => $token
				);
			return  curlPost($this->host,$data);
		}
		public function getUserInfoByuid($uid){
			$data = array(
				'action' => 'userinfoByuid',
				'uid' => $uid
				);
			return  curlPost($this->host,$data);
		}
		/**
		*获取menu
		*@param String token
		*@return mixed
		**/
		public function getMenu($token){
			$data = array(
				'action' => 'menu',
				'token' => $token
				);
			return  curlPost($this->host,$data);
		}

		/**
		*获取用户信息
		*@param String token
		*@return mixed
		**/
		public function getClientList($token){
			$data = array(
				'action' => 'clients',
				'token' => $token
				);
			return  curlPost($this->host,$data);
		}
		
		


	}